package com.java.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author jingjintao
 * @date 2021/6/21 - 23:05
 **/
public class Filter2 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {

        System.out.println("Filter2 前置代码");
        System.out.println("Filter2 线程名:"+Thread.currentThread().getName());
        System.out.println("Filter2username = "+servletRequest.getParameter("username"));
        System.out.println("Filter2 key1 = "+servletRequest.getAttribute("key1"));
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("Filter2 线程名:"+Thread.currentThread().getName());
        System.out.println("Filter2 后置代码");
    }

    @Override
    public void destroy() {

    }
}
